#include <bits/stdc++.h>
using namespace std;

class Solution
{
public:
    int main()
    {
        int n;
        cin >> n;
        int minVal, maxVal;
        cin >> minVal;
        maxVal = minVal;
        for (int i = 1; i < n; ++i)
        {
            int val;
            cin >> val;
            minVal = min(minVal, val);
            maxVal = max(maxVal, val);
        }
        cout << maxVal - minVal;
        return 0;
    }
};

#ifndef __LOCAL_TEST__
int main()
{
    return Solution().main();
}
#endif